$(function () {
	ininUser();
	searchData();
});
function searchData(){
	getbaseList(1);
	findSummaryRate();
}
function getbaseList(init){
	if(init==1)$("#baseForm .pageNum").val(1);	
	JY.Model.loading();
	
	JY.Ajax.doRequest("baseForm",jypath +'/call/importStatistics/list',null,function(data){
		 $("#baseTable tbody").empty();
		 var page=data.obj;
		//数据集合
    	 var results=page.rows;
    	 
    	 //分页数据
     	 var pageNum=page.pageNumber,pageSize=page.pageSize,totalRecord=page.total;
    	 var html="";
    		 if(results!=null&&results.length>0){
        		 var leng=(pageNum-1)*pageSize;//计算序号
        		 for(var i = 0;i<results.length;i++){
            		 var l=results[i];
            		 var downloadUrl=jypath +"/call/importError/download?impId="+l.id;
            		 var notDialUrl=jypath +"call/callCustomer/callCustomerList?impId="+l.id+"&status=0";
            		 var notFollowUrl=jypath +"call/callCustomer/callCustomerList?impId="+l.id+"&status=1";
            		 var effectiveUrl=jypath +"call/callCustomer/callCustomerList?impId="+l.id+"&status=3";
            		 var invalidUrl=jypath +"call/callCustomer/callCustomerList?impId="+l.id+"&status=2";
            		 
            		 html+="<tr>";
            		 html+="<td class='center'>"+(i+leng+1)+"</td>";
            		 html+="<td class='center'>"+l.title+"</td>";
            		 html+="<td class='center'>"+JY.Object.notEmpty(l.createUserName)+"</td>";
            		 html+="<td class='center'>"+JY.Date.Default(l.createTime)+"</td>";
            		 html+="<td class='center'>"+l.total+"</td>";
            		 html+="<td class='center'>"+l.successCount+"</td>";
            		 html+="<td class='center'><a href='"+downloadUrl+"'>"+l.failCount+"</a></td>";
            		 html+="<td class='center'>"+JY.Object.notEmpty(l.successRatio)+"%</td>";
            		 html+="<td class='center'><a href='"+notDialUrl+"'>"+JY.Object.notEmpty(l.notDialCount)+"</a></td>";
            		 html+="<td class='center'><a href='"+notFollowUrl+"'>"+JY.Object.notEmpty(l.notFollowCount)+"</a></td>";
            		 html+="<td class='center'><a href='"+effectiveUrl+"'>"+JY.Object.notEmpty(l.effectiveCount)+"</a></td>";
            		 html+="<td class='center'><a href='"+invalidUrl+"'>"+JY.Object.notEmpty(l.invalidCount)+"</a></td>";
            		 html+="<td class='center'>"+JY.Object.notEmpty(l.effectiveRate)+"%</td>";
            		 html+="</tr>";		 
            	 } 
        		 $("#baseTable tbody").append(html);
        		 JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"getbaseList");
        	 }else{
        		html+="<tr><td colspan='12' class='center'>没有相关数据</td></tr>";
        		$("#baseTable tbody").append(html);
        		$("#pageing ul").empty();//清空分页
        	 }	 
    	    JY.Model.loadingClose();
	 });
}

function ininUser(){
	$.ajax({
		type: 'post',
        url: jypath+"/system/user/findRoleUser",
	    data: {
	    },
	    dataType:'json',
	    success: function(res){
	    	$("#createUserId").empty();
	    	var list=res.obj;
	    	var option='<option value="" >全部</option>';
    		$.each(list, function(index, row) {
    			option=option+'<option value="'+row.id+'">'+row.userName+'</option>';
    		});
    		$("#createUserId").html(option);
	    	
	    }
	});
}

function findSummaryRate(){
	JY.Ajax.doRequest("baseForm",jypath +'/call/importStatistics/findSummaryRate',null,function(data){
		var map=JSON.parse(data.obj);
		var successRate=map.successRate;
		var effectiveRate=map.effectiveRate;
		if(null!=successRate && successRate!=""){
			option.series[0].data[0].value = successRate;
			mainChart.setOption(option, true);
		}
		if(null!=effectiveRate && effectiveRate!=""){
			option1.series[0].data[0].value = effectiveRate;
			main1Chart.setOption(option1, true);
		}
	});
}

